﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IoTCM
{
    [Flags]
    public enum UserRights
    {
        None = 0,
        Read = 1,
        Write = 2
    }

    public class UserService
    {
        // ------------------------ WARNING!!! ------------------------
        // This is very, very basic.  Do *not* use it as-is in a production environment
        // or you're going to have an "Internet of Insecure Things"
        // ------------------------ WARNING!!! ------------------------

        public UserRights GetUserRights(string username, string password)
        {
            // TODO: don't check the password itself, check a hash instead.  That way your
            //       passwords aren't stored (and thereby aren't stealable)
            if (password != "password") return UserRights.None;

            // TODO: get user credentials from some sort of credential store
            switch (username.ToLower())
            {
                case "reader":
                    return UserRights.Read;
                case "writer":
                    return UserRights.Read | UserRights.Write;
                default:
                    return UserRights.None;
            }
        }

    }
}
